<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
         <!--
              1.创建Ajax对象
              2.设置发送的方法和内容
              3.发送数据
              4、监听数据
              5.处理数据
        -->
        <!-- <script src="getAjax.js" type="text/javascript" charset="utf-8"></script> -->
        <script src="getAjax进阶.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript">
            /* 
                var xhr = new XMLHttpRequest();

                 xhr.open("GET","http://127.0.0.1:5500/18/03_%E5%AE%9E%E8%B7%B5/1ajax/wt.txt?username=wt&password=123456");
                //xhr.open("post","http://127.0.0.1:5500/18/03_%E5%AE%9E%E8%B7%B5/1ajax/wt.txt");
                
                xhr.send();
                //xhr.send("username = wt&password=123456");

            xhr.onreadystatechange = function(){
                if(xhr.status = 200&&xhr.readyState==4){
                    console.log("成功获取数据！");
                    console.log(xhr);
                    console.log(xhr.status);
                    console.log(xhr.readyState);

                    var res = xhr.response;
                    var h2 = document.createElement("h2");
                    h2.innerHTML = res;
                    document.body.appendChild(h2);
                }
            } */
            var HttpUrl = "https://api.apiopen.top/getJoke";
            var data = {
                page:1,
                count:10,
                type:"video"
            }
            

             getAjax(HttpUrl,data,function(xhr){
                 
                 var dataObj = JSON.parse(xhr.response);
                 console.log(dataObj);
             });

    
        </script>
    </body>
</html>